import request from '@/utils/request'
import Qs from 'qs'
import process from 'shelljs'
export function list(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.biaozhun',
      _mt: 'list',
      ...query
    }
  })
}

export function active(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.biaozhun',
      _mt: 'updateStatus',
      ...data
    })
  })
}

export function create(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.biaozhun',
      _mt: 'create',
      shopBiaozhunDO: JSON.stringify(data)
    })
  })
}

export function update(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.biaozhun',
      _mt: 'update',
      shopBiaozhunDO: JSON.stringify(data)
    })
  })
}

export function del(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.biaozhun',
      _mt: 'delete',
      ...data
    })
  })
}

export function batchDelete(ids) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.biaozhun',
      _mt: 'batchDelete',
      ids: JSON.stringify(ids)
    })
  })
}

export function detail(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.biaozhun',
      _mt: 'detail',
      ...data
    })
  })
}

export function listByBiaozhun(shopId) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.biaozhun',
      _mt: 'getBiaozhunByShopId',
      shopId: shopId
    }
  })
}
export function getBiaozhunByPId(shopId, gongchengPxuhao) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.biaozhun',
      _mt: 'getBiaozhunByPId',
      shopId: shopId,
      gongchengPxuhao: gongchengPxuhao
    }
  })
}

export function biaozhunMonthLyOutExcel(shopId, start, end) {
  if (shopId === undefined) {
    shopId = ''
  }
  start = start && start !== '' ? start : ''
  end = end && end !== '' ? end : ''
  const exportOrderSummaryHref = process.env.HOST + '/excel/getAllBiaozhun'
  const a = document.createElement('a')
  a.setAttribute('href', encodeURI(exportOrderSummaryHref + '?shopId=' + shopId + '&startStr=' + start + '&endStr=' + end))
  a.click()
  a.remove()
}

export function biaozhunUpload(data) {
  debugger
  return request({
    url: process.env.HOST + '/excel/batchUpload',
    method: 'post',
    params: {

      ...data
    }
  })
}
